﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace StudentsImplementation
{
    public class Student
    {
        private string name;
        private int age;
        private string gender;
        private int classNumber;
        private int ssn;
        private DateTime dateOfBirth;

        public Student(string name, int age, string gender, int classNumber)
        {
            this.Name = name;
            this.Age = age;
            this.Gender = gender;
            this.ClassNumber = classNumber;
        }

        public Student(string name, int age, string gender, int classNumber, 
            int ssn, DateTime dateOfBirth)
        {
            this.Name = name;
            this.Age = age;
            this.Gender = gender;
            this.ClassNumber = classNumber;
            this.Ssn = ssn;
            this.DateOfBirth = dateOfBirth;
        }

        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                if (value.Length >= 10 && value.Length <= 50)
                {
                    name = value;
                }
                throw new InvalidStudentException(string.Format(
                    "Name length is out of range. The given name is: {0}", value));
            }
        }

        public int Age
        {
            get
            {
                return age;
            }
            set
            {
                if (value >= 7 && value <= 18)
                {
                    age = value;
                }
                throw new InvalidStudentException(string.Format(
                    "The age should be between 7 and 18 years. The given age is: {0}", value));
            }
        }

        public string Gender
        {
            get
            {
                return gender;
            }
            set
            {
                if (value == "male" || value == "female")
                {
                    gender = value;
                }
                throw new InvalidStudentException(string.Format(
                    "Invalid gender. The given gender is: {0}", value));
            }
        }

        public int ClassNumber
        {
            get
            {
                return classNumber;
            }
            set
            {
                if (value >= 1 && value <= 11)
                {
                    classNumber = value;
                }
                throw new InvalidStudentException(string.Format(
                    "Invalid class number. The given class number is: {0}", value));
            }
        }

        public int Ssn
        {
            get
            {
                return ssn;
            }
            private set
            {
                if (value > 0 && value < 1000000000)
                {
                    ssn = value;
                }
                throw new ArgumentException(string.Format(
                    "The SSN entered is not valid. It should be 9 digits long. The entered SSN is: {0}",
                    value));
            }
        }

        public DateTime DateOfBirth
        {
            get
            {
                return dateOfBirth;
            }
            set
            {
                if (value.Year >= 1900 && value.Year <= 2010)
                {
                    dateOfBirth = value;
                }
                throw new ArgumentException(string.Format(
                    "The entered birth date is invalid. The entered date is: {0}",
                    value));
            }
        }
    }
}
